home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / hal / scripts / linux / hal-system-lcd-get-brightness-linux < prev    next >
Encoding:
Text File  |  2009-07-05  |  2.6 KB  |  79 lines

  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2005 Richard Hughes <richard@hughsie.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9.  
  10. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
  11.     value="`hal-system-power-pmu getlcd`"
  12.     if [ $? -ne 0 ]; then
  13.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  14.         echo "hal-system-power-pmu getlcd returned != 0" >&2
  15.         exit 1
  16.     fi
  17.     exit ${value}
  18. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sonypi" ]; then
  19.     value="`hal-system-sonypic getlcd`"
  20.     if [ $? -ne 0 ]; then
  21.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  22.         echo "hal-system-sonypic getlcd returned != 0" >&2
  23.         exit 1
  24.     fi
  25.     exit ${value}
  26. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sony-nvidia" ]; then
  27.     # smartdimmer -g
  28.     value=$(( $(smartdimmer -g | awk '{print $3;}') - 15 ))
  29.     if [ $? -ne 0 ]; then
  30.         echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  31.         echo "smartdimmer -g returned != 0" >&2
  32.         exit 1
  33.     fi
  34.     exit ${value}
  35. fi
  36.  
  37. # Check for file existance and that it's readable
  38. if [ ! -r $HAL_PROP_LINUX_ACPI_PATH ]; then
  39.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  40.     echo "$HAL_PROP_LINUX_ACPI_PATH not readable!" >&2
  41.     exit 1
  42. fi
  43.  
  44. if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "toshiba" ]; then
  45.     # cat /proc/acpi/toshiba/lcd
  46.     #  brightness:              5
  47.     #  brightness_levels:       8
  48.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep brightness: | awk '{print $2;}'`"
  49. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "asus" ]; then
  50.     # cat /proc/acpi/asus/brn
  51.     #  5
  52.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  53. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "panasonic" ]; then
  54.     # cat /proc/acpi/pcc/brightness
  55.     #  5
  56.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  57. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "ibm" ]; then
  58.     # cat /proc/acpi/ibm/brightness
  59.     #  level:          5
  60.     #  commands:       up, down
  61.     #  commands:       level <level> (<level> is 0-7)
  62.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | grep level: | awk '{print $2;}'`"
  63. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "sony" ]; then
  64.     # cat /proc/acpi/sony/brightness
  65.     #  5
  66.     value="`cat $HAL_PROP_LINUX_ACPI_PATH`"
  67.     value=$(($value-1))
  68. elif [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "omnibook" ]; then
  69.     # cat /proc/omnibook/lcd
  70.     #  LCD brightness:  7
  71.     value="`cat $HAL_PROP_LINUX_ACPI_PATH | awk '{print $3;}'`"
  72. else
  73.     echo "org.freedesktop.Hal.Device.LaptopPanel.NotSupported" >&2
  74.     echo "No ACPI method found" >&2
  75.     exit 1
  76. fi
  77.  
  78. exit ${value}
  79.